//
//  FKChooseCouponCell.m
//  WanTao
//
//  Created by Macbook Pro on 2019/4/11.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKChooseCouponCell.h"

@interface FKChooseCouponCell ()

@property (nonatomic, weak) UILabel *titleLabel;
@property (nonatomic, weak) UILabel *noUseLabel;
@property (nonatomic, weak) UILabel *subTitleLabel;
@property (nonatomic, weak) UIImageView *iconView;

@end

@implementation FKChooseCouponCell

- (void)setupSubviews
{
    [super setupSubviews];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = [UIColor clearColor];
    
    UILabel *titleLabel = [UILabel fk_labelWithFont:fk_adjustFont(14) textColor:fkColor333333];
    [self.contentView addSubview:titleLabel];
    self.titleLabel = titleLabel;
    
    UILabel *noUseLabel = [UILabel fk_labelWithFont:fk_adjustFont(14) textColor:fkColor333333 text:@"不使用"];
    [self.contentView addSubview:noUseLabel];
    self.noUseLabel = noUseLabel;
    
    UILabel *subTitleLabel = [UILabel fk_labelWithFont:fk_adjustFont(11) textColor:fkColor999999];
    [self.contentView addSubview:subTitleLabel];
    self.subTitleLabel = subTitleLabel;
    
    UIImageView *iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"address_choose_uncheck"]];
    [self.contentView addSubview:iconView];
    self.iconView = iconView;
    iconView.highlightedImage = [UIImage imageNamed:@"address_choose_selected"];
    
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(12);
        make.bottom.equalTo(self.contentView.mas_centerY).offset(-4);
    }];
    [noUseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(titleLabel);
        make.centerY.offset(0);
    }];
    [subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(titleLabel);
        make.top.equalTo(self.contentView.mas_centerY).offset(4);
    }];
    [iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-12);
        make.centerY.offset(0);
    }];
}

- (void)setData:(id)data
{
    [super setData:data];
    
    self.titleLabel.text = data[@"title"];
    self.subTitleLabel.text = data[@"minprice"] ? fkFORMAT(@"满%@元使用", data[@"minprice"]) : @"";
    self.noUseLabel.hidden = data[@"title"];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    self.iconView.highlighted = selected;
}

@end
